import { getOrderDetail } from "@src/api/points";
import router from "@src/router";
import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import base from "@src/store/base";

Component({
  behaviors: [router.routerBehavior, storeBindingsBehavior],
  storeBindings: [{
    store: base,
    fields: ['themeColor', 'themeTitleColor'],
  }],
  data: {},
  methods: {
    onLoad(options) {
      this.setData({ orderNo: options.orderNo })
      this.getOrder();
    },
    navigateToCouponDetail(e) {
      console.log('e', e);
      let couponCode = e.currentTarget.dataset.item.code;
      let str = /^8128\d{16,20}$/
      if (str.test(couponCode)) {
        router.push({ name: 'member/couponDetailNew', params: { couponCode: couponCode, type: 1 } })
      } else {
        router.push({ name: 'member/couponDetail', params: { couponCode: couponCode, couponStatus: 1 } })
      }
    },
    getOrder() {
      let data = {
        orderNo: this.data.orderNo,
      };
      return getOrderDetail(data).then(res => {
        if (res.code === 0) {
          this.setData({ pointOrderData: res.data })
        }
      })
    },
  }
})
